import initTranslations from '../i18n'
import TranslationProvider from '@/components/TranslationProvider'
import { Container, Typography, Box } from '@mui/material'
import IndexCard, { IndexCardProps } from '@/app/[locale]/IndexCard'
import examples from '@/nxtstart.config.json'
import { PageProps } from '@/util/types'

const libraries: IndexCardProps[] = [
  {
    imageLink: 'https://nextjs.org/favicon.ico',
    title: 'Next JS',
    description:
      'This framework builds the foundation of this template, alowing for server-side-rendering and connecting front- and backend. Find in-depth information about Next.js features and API.',
    hrefDocs: 'https://nextjs.org/docs',
    hrefExample: '/serverActions',
    additionalLinks: [
      {
        label: 'YT Tutorial',
        href: 'https://www.youtube.com/watch?v=9P8mASSREYM&list=PLC3y8-rFHvwgC9mj0qv972IO5DmD-H0ZH',
      },
    ],
  },
  {
    imageLink: 'https://avatars.githubusercontent.com/u/6019716?s=48&v=4',
    title: 'ESLint',
    description:
      'ESLint can be used to enforce codestyle across the project and prevent errors. Run the lint run configuration or setup automatic linting depending on your code editor.',
    hrefDocs: 'https://eslint.org/',
    hrefExample: undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://avatars.githubusercontent.com/u/25822731?s=200&v=4',
    title: 'Prettier',
    description:
      'Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account.',
    hrefDocs: 'https://prettier.io/',
    hrefExample: undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://images.emojiterra.com/google/noto-emoji/unicode-15.1/color/svg/1f436.svg',
    title: 'Husky Pre-Commit Hook',
    description:
      'Husky allows the use Pre-Commit hooks that run code automatically before code is pushed to the repository. This can be used for automatic linting and code formatting.',
    hrefDocs: 'https://typicode.github.io/husky/',
    hrefExample: undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://swr.vercel.app/favicon/safari-pinned-tab.svg',
    title: 'SWR Data Fetching',
    description:
      'SWR is used to fetch data inside components at runtime on client side. Provides good error and loading indicators using stale-while-revalidate.',
    hrefDocs: 'https://swr.vercel.app/',
    hrefExample: examples.includes('swr') ? '/swr' : undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://raw.githubusercontent.com/mui/material-ui/master/docs/public/static/logo.svg',
    title: 'Material UI',
    description: 'Used as the main design library. Browse the catalog of components provided by Material UI.',
    hrefDocs: 'https://mui.com/material-ui/getting-started/overview/',
    hrefExample: examples.includes('mui') ? '/responsive' : undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://raw.githubusercontent.com/reduxjs/redux/master/logo/logo.png',
    title: 'React Redux + Toolkit',
    description:
      'Allows easy state management across pages and components in your react application. The toolkit reduces needed code for the state store.',
    hrefDocs: 'https://react-redux.js.org/introduction/getting-started#api-overview',
    hrefExample: examples.includes('redux') ? '/redux' : undefined,
    additionalLinks: [],
  },
  {
    imageLink:
      'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIALoAugMBEQACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAAAQYCBQcDBP/EAEwQAAIBAwEDBQgPBQUJAAAAAAABAgMEEQUGITESQVFhcRMiMjOBkcHRBxQVFiNCUlRVk6GiseHiQ3KjpNIXYmODlCU0NUVTc4SSwv/EABoBAQACAwEAAAAAAAAAAAAAAAABBQIEBgP/xAA0EQEAAgECBAIJAgcAAwAAAAAAAQIDBBEFEiExE6EUFTJBUVJhgeFi0SIjM0JxkbE0Q1P/2gAMAwEAAhEDEQA/AO4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARJ8mLfQCFQltvyZNe5/B48d+RpTrNvcu44PvHt+X5Ftvn/l+7qrfkR6b9D1N+vy/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8mVeG6ie+zCeIYY+L7KOy1R47vcpLois/ibFOFTPt2/08LcTj+2rZ2mhWNs+Uqbqy+VUeceTgb2LQYMfXbeWnk1ua/TfaGzjHkrC4G3EbNVJI1+pVr2EORYW3Lm/jykko+Q1s9s0Rtir1e+CuKZ3yW6KzV0bVa1SVSpRc5yeXJ1I7/tKi2j1Np3mFvXWaasbRLH3D1L5v9+PrI9B1HysvTtP8x7hal83+/H1j0HUfKenaf5j3C1L5v8Afj6x6DqPlPTtP8x7hal83+/H1kW0Gon+09O0/wAwtC1LP+7/AH4+sw9X6j5T07T/ADPals5fzffdyguuWTOvDM899oYW4hhjtu2VrsxRhLlXNWVT+7HvV5+JuYuFUrO+Sd/JqZOI3npSNm6oW9K3pqFCnGEVzRRZ0x1xxtSNlfe9rzvad3sZsQAAAAAIayAwAwAwBIAAAAjkkBgbBgbBgbBgbBgnYMAEsASAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//9k=',
    title: 'D3 JS',
    description:
      'JavaScript library for producing dynamic, interactive data visualizations in web browsers. It makes use of Scalable Vector Graphics, HTML5, and Cascading Style Sheets standards.',
    hrefDocs: 'https://d3js.org/',
    hrefExample: examples.includes('d3') ? '/d3' : undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://better-auth.com/branding/svg/better-auth-mark-light.svg?dpl=dpl_BYZ8RZmPumL3C3gshSzqCMLxA3Rx',
    title: 'Better Auth',
    description:
      'Easy to implement user authentication and session management. Allows for third party providers and own implmentations for the login.',
    hrefDocs: 'https://better-auth.com/docs/introduction',
    hrefExample: examples.includes('auth') ? '/restrictedPage' : undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://avatars.githubusercontent.com/u/17219288?s=200&v=4',
    title: 'Prisma',
    description: 'Provides client for accessing databases in Next JS. Simplifies data modeling amd sql queries.',
    hrefDocs: 'https://www.prisma.io/docs',
    hrefExample: examples.includes('prisma') ? '/prisma' : undefined,
    additionalLinks: [],
  },
  {
    imageLink:
      'https://www.gitbook.com/cdn-cgi/image/width=40,dpr=2,height=40,fit=contain,format=auto/https%3A%2F%2F4042378089-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fspaces%252F-L9iS6WpW81N7RGRTQ-K%252Favatar.png%3Fgeneration%3D1523345851027218%26alt%3Dmedia',
    title: 'React I18Next',
    description:
      'Powerful internationalization framework. Check out the source code for the index page and prisma page to see the different ways of using it.',
    hrefDocs: 'https://react.i18next.com/getting-started',
    hrefExample: undefined,
    additionalLinks: [{ label: 'Tutorial', href: 'https://i18nexus.com/tutorials/nextjs/react-i18next' }],
  },
  {
    imageLink: 'https://ui-avatars.com/api/?name=Web+Worker&length=2',
    title: 'Web Worker',
    description:
      'When creating progressive visualizations Web Workers can help by offloading intensive computations onto another thread in the browser.',
    hrefDocs: 'https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers',
    hrefExample: examples.includes('webWorker') ? '/webworker' : undefined,
    additionalLinks: [
      { label: 'Example Repo', href: 'https://github.com/vercel/next.js/tree/canary/examples/with-web-worker' },
    ],
  },
  {
    imageLink: 'https://ui-avatars.com/api/?name=Server+Sent+Events&length=3',
    title: 'Server-Sent-Events',
    description:
      'Make use of server-sent-events for large computations that can already be displayed in chunks while the rest is still being computed.',
    hrefDocs: 'https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events',
    hrefExample: examples.includes('sse') ? '/sse' : undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://framerusercontent.com/images/3ydDYhTbVKKzF5xDzZpZKoMmc.png',
    title: 'Framer Motion',
    description:
      'Framer motion provides simple to use animations on a broad spectrum. From an animated button and scrolling progress bars to page transitions.',
    hrefDocs: 'https://www.framer.com/motion/?utm_source=motion-readme-docs',
    hrefExample: undefined,
    additionalLinks: [],
  },
  {
    imageLink: 'https://ui-avatars.com/api/?name=Progressive+Web+App&length=3',
    title: 'PWA',
    description:
      'Progressive web apps improve loading for repeating visitors and allow users to install the webapp to make it run like a native app. Can be used together with service workers to further improve app like feel.',
    hrefDocs: 'https://web.dev/learn/pwa',
    hrefExample: undefined,
    additionalLinks: [
      { label: 'SW API', href: 'https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API' },
    ],
  },
  {
    imageLink: 'https://asset.brandfetch.io/idIq_kF0rb/idv3zwmSiY.jpeg?updated=1667565306852',
    title: 'Cypress',
    description:
      'Cypress is a next generation front end testing tool built for the modern web. They address the key pain points developers and QA engineers face when testing modern applications.',
    hrefDocs: 'https://docs.cypress.io/guides/overview/why-cypress',
    hrefExample: undefined,
    additionalLinks: [],
  },
]

export default async function LandingPage(props: { params: PageProps }) {
  const { locale } = await props.params
  const { t, options } = await initTranslations(locale, ['common', 'indexPage'])

  return (
    <TranslationProvider namespaces={options.ns} locale={locale}>
      <Container
        sx={{
          my: 2,
          width: '100%',
          height: '100%',
          display: 'flex',
          flexDirection: 'column',
          justifyContent: 'center',
          alignItems: 'center',
        }}
      >
        <Box
          sx={{
            textAlign: 'center',
          }}
        >
          <Typography variant="h3">{t('appName')}</Typography>
          <Typography variant="h5">{t('appDescription', { ns: 'indexPage' })}</Typography>
          <Typography sx={{ my: 3 }}>{t('getStarted', { file: 'page.tsx', ns: 'indexPage' })}</Typography>
        </Box>

        <Box
          sx={{
            width: '90dvw',
            p: 1,
            display: 'flex',
            flexDirection: 'row',
            flexWrap: 'wrap',
            justifyContent: 'center',
          }}
        >
          {libraries.map((lib) => (
            <IndexCard
              key={lib.title}
              imageLink={lib.imageLink}
              title={lib.title}
              description={lib.description}
              hrefDocs={lib.hrefDocs}
              hrefExample={lib.hrefExample}
              additionalLinks={lib.additionalLinks}
            />
          ))}
        </Box>
      </Container>
    </TranslationProvider>
  )
}
